<template>
	<page-meta :page-style="'overflow:'+(popupImg?'hidden':'visible')"></page-meta>
	<view class="groupactiveauditlist">
		<view class="groupactiveauditlist_top_block">
			<view class="groupactiveauditlist_table_header">
				<uni-row gutter="8">
					<uni-col :span="4">
						<view class="text-c">ID</view>
					</uni-col>
					<uni-col :span="10">
						<view class="text-c">姓名</view>
					</uni-col>
					<uni-col :span="10">
						<view class="text-c">报名日期</view>
					</uni-col>
				</uni-row>
			</view>
		</view>
		<view class="f-14">
			<view v-for="(item,index) in list" :key="item.id" class="groupaudit_cell" @click="openInfo(item.id)">
				<uni-row gutter="8">
					<uni-col :span="4">
						<view class="text-c">{{item.id}}</view>
					</uni-col>
					<uni-col :span="10">
						<view class="text-c ellipsis">{{item.name}}</view>
					</uni-col>
					<uni-col :span="10">
						<view class="text-c">{{item.create_time?item.create_time.substring(0,10):''}}</view>
					</uni-col>
				</uni-row>
			</view>
			<view class="page_bottom_loading" :style="'padding-bottom:'+pdbottom+'rpx;'">{{loadingTitle}}</view>
		</view>
		<view v-if="popupImg" class="mask_box" @click="closePopup"></view>
		<view class="popup_img_box" v-if="popupImg">
			<!-- <image class="popup_img" :src="onlinePic+'popup_img.png'" mode="widthFix"></image> -->
			<image style="width: 300rpx;height: 300rpx;" show-menu-by-longpress :src="onlinePic+'qrcode.jpg'"></image>
			<!-- <view class="popup_text_box">
				<text>{{card_add_popup}}</text>
			</view>
			<view class="popup_sub">
				<view class="sub left" @click="closePopup">关闭弹框</view>
				<view class="sub right" @click="joinGroup">加入车友会</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		getGroupTestDriveList,
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				popupImg: false,
				club_id: '',
				huodong_id: '',
				params: {
					club_id: '',
					page: 1,
					size: 15,
				},
				list: [],
				loadingTitle: '',
				onlinePic: app.globalData.onlinePic,
				pdbottom: uni.getSystemInfoSync().safeAreaInsets.bottom ? uni.getSystemInfoSync().safeAreaInsets.bottom +
					60 : 60,
			};
		},
		onShow() {
			if (!uni.getStorageSync('access_token')) {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}
			if (uni.getStorageSync('userinfo').is_staff == 0) {
				uni.switchTab({
					url: '/pages/index/index'
				})
			} else {
				if (uni.getStorageSync('onload')) {
					this.params.page = 1
					this.list = []
					this.getGroupTestDriveList()
					uni.removeStorage({
						key: 'onload'
					})
				}
			}
		},
		onLoad(options) {
			if (uni.getStorageSync('userinfo').is_staff != 0) {
				this.params.club_id = options.club_id ? options.club_id : ''
				this.getGroupTestDriveList()
			}
		},
		methods: {
			getGroupTestDriveList() {
				getGroupTestDriveList(this.params).then(res => {
					if (res.state == 1) {
						this.list = [...this.list, ...res.data.data]
						this.current_page = res.data.current_page
						this.last_page = res.data.last_page
						if (this.list.length == 0) {
							this.loadingTitle = "- 暂无更多 -"
						}
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},

			changeTabs(index) {
				this.params.status = index
				this.params.page = 1
				this.list = []
				this.getGroupTestDriveList()
			},
			openInfo(id) {
				uni.navigateTo({
					url: '/pages/groupmanage/grouptestdriveinfo?drive_id=' + id
				})
			}
		},
		onPullDownRefresh() {
			this.params.page = 1
			this.list = []
			this.getGroupTestDriveList()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if (this.current_page < this.last_page) {
				this.showLoading = true
				this.params.page = this.params.page + 1
				this.getGroupTestDriveList()
			} else {
				this.showLoading = false
				if (this.list.length > 0) {
					this.loadingTitle = "- 已经到底了 -"
				} else {
					this.loadingTitle = "- 暂无更多 -"
				}

			}
		}
	}
</script>

<style lang="scss">
	.groupactiveauditlist {
		padding: 0 30rpx 50rpx 30rpx;

		.groupactiveauditlist_top_block {
			padding-top: 30rpx;
			position: sticky;
			top: 0;
			z-index: 1;
			background-color: #ffffff;

			.groupactiveauditlist_tabs {
				height: 80rpx;
				font-size: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-around;
				border-radius: 8rpx;
				border: 2rpx solid #E9E9E9;

				.groupactiveauditlist_tabs_cell {
					width: 25%;
					height: 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-right: 4rpx solid #000000;
				}

				.groupactiveauditlist_tabs_cell:last-child {
					border-right: 0;
				}

				.tabs_on {
					color: #00A0DC;
				}

				// .tabs_on:first-child {
				// 	border-top-left-radius: 8rpx;
				// 	border-bottom-left-radius: 8rpx;
				// }

				// .tabs_on:last-child {
				// 	border-top-right-radius: 8rpx;
				// 	border-bottom-right-radius: 8rpx;
				// }
			}

			.groupactiveauditlist_table_header {
				font-size: 24rpx;
				margin: 40rpx 0 30rpx 0;
				padding: 30rpx 0;
				border-radius: 8rpx;
				background-color: #F2F2F2;
			}
		}

		.groupaudit_cell {
			padding: 30rpx 0;
			margin-bottom: 30rpx;
			border-radius: 8rpx;
			background-color: #F7F7F7;

			.green {
				color: #07C061;
			}

			.red {
				color: #EE2A2A;
			}

			.black {
				color: #666666;
			}
		}

		.popup_img_box {
			position: fixed;
			top: 150rpx;
			left: 60rpx;
			right: 16rpx;
			z-index: 1001;

			.popup_img {
				width: 100%;
				vertical-align: middle;
			}

			.popup_text_box {
				color: #666666;
				font-size: 28rpx;
				position: absolute;
				top: 20%;
				left: 66rpx;
				right: 115rpx;
				z-index: 1002;
				line-height: 42rpx;
			}

			.pop_close_icon_box {
				position: absolute;
				bottom: -80rpx;
				left: 0;
				right: 0;
				z-index: 1002;
				text-align: center;
			}

			.popup_sub {
				margin-top: 20rpx;
				margin-right: 44rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.sub {
					width: 287rpx;
					height: 80rpx;
					line-height: 80rpx;
					color: #FFFFFF;
					font-size: 36rpx;
					background-color: #00A0DC;
					border-radius: 8rpx;
					text-align: center;


					&.left {
						color: #00A0DC;
						background-color: #FFFFFF;
					}
				}
			}

		}
	}
</style>